export default class PureObservable {
  observers: Set<Pick<any, "notify">>
  constructor() {
    this.observers = new Set()
  }
  observe(e) {
    this.observers.add(e)
    const that = this
    return {
      renew() {
        that.observers.add(e)
      },
      cancel() {
        that.removeObserver(e)
      }
    }
  }
  removeObserver(e) {
    this.observers.delete(e)
  }
  notify() {
    for (const e of this.observers) e.notify()
  }
}
